<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <block name="style">
        <link rel="stylesheet" href="__MYCSS__/main.min.css">
    </block>
</head>
<extend name="Public/base" />
<block name="body">

    <body>
        <ol class="breadcrumb">
            <li><a href="#">财务管理</a></li>
            <li class="active">发票收到登记表</li>
        </ol>
        <p>
            <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">查询</a>
            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#addModal">添加</button>
        </p>
        <div class="collapse" id="collapseExample">
            <div class="well">
                <form method="GET" action="{:U('lst')}">
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="cpf">出票方</label>
                                <select class="form-control " name="cpf">
                                <option value="">--请选择--</option>
                                <volist name="cpf_arr" id="cpf">
                                    <option value="{$cpf}">{$cpf}</option>
                                </volist>
                            </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="gys">供应商</label>
                                <select class="form-control" name="gys">
                                <option value="">--请选择--</option>
                                 <volist name="gys_arr" id="gys">
                                    <option value="{$gys}">{$gys}</option>
                                </volist>
                            </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="spf">收票方</label>
                                <select class="form-control" name="spf">
                                <option value="">--请选择--</option>
                                <volist name="spf_arr" id="spf">
                                    <option value="{$spf}">{$spf}</option>
                                </volist>
                            </select>
                            </div>
                        </div>
                        <div class="col-lg-1">
                            <div class="form-group">
                                <label for="year">所属年份：</label>
                                <select class="form-control father_select year_select" name="year">
                                <option value="">--请选择--</option>
                            </select>
                            </div>
                        </div>
                        <div class="col-lg-1">
                            <div class="form-group">
                                <label for="month">所属月份：</label>
                                <select class="form-control son_select month_select" name="month" disabled="disabled">
                                <option value="">--请选择--</option>
                            </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group" style="margin-top: 24px;">
                                <button type="submit" class="btn btn-success">查询</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>


        <div class="panel panel-default">
            <div class="panel-heading">发票收到登记表</div>

            <div class="surface_table">
                <div class="table-head">
                    <table class="table table-bordered">
                        <thead>
                            <tr class="table-h">
                                <th>出票方</th>
                                <th>供应商</th>
                                <th>收票方</th>
                                <th>发票类型</th>
                                <th>开票日期</th>
                                <th>发票号</th>
                                <th>不含税金额</th>
                                <th>税率</th>
                                <th>税额</th>
                                <th>价税合计</th>
                                <th>所属月份</th>
                                <th>是否认证</th>
                                <th>认证时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <div class="table-body">
                    <table class="table table-hover table-bordered">
                        <tbody>
                            <volist name="lsts" id="list">
                                <tr>
                                    <td>{$list.cpf}</td>
                                    <td>{$list.gys}</td>
                                    <td>{$list.spf}</td>
                                    <td>{$list.fplx}</td>
                                    <td>{$list.kprq}</td>
                                    <td>{$list.fph}</td>
                                    <td class="count_je">{$list.je}</td>
                                    <td>{$list.sl}</td>
                                    <td class="count_se">{$list.se}</td>
                                    <td class="count_jshj">{$list.jshj}</td>
                                    <td>{$list.yf}</td>
                                    <td>{$list.rz}</td>
                                    <td>{$list.rzsj}</td>
                                    <td>
                                        <button type="button" data-id="1" class="btn btn-warning update_btn" data-toggle="modal" data-target="#updateModal">修改</button>
                                        <a class="btn btn-danger delete_btn" href="{:U('del',array('id'=>$list['id']))}" role="button">删除</a>
                                    </td>
                                </tr>
                            </volist>
                            <tr>
                                <td colspan="6" style="text-align: center">总计</td>
                                <td id="count_je" class="count"></td>
                                <td></td>
                                <td id="count_se" class="count"></td>
                                <td id="count_jshj" class="count"></td>
                                <td colspan="4"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--添加面板-->
        <div class="modal fade bs-example-modal-lg" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">增加发票收到登记表</h4>
                    </div>
                    <div class="modal-body">
                        <form id="khzyForm" class="public_form" action="{:U('add')}" method="post">
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addcpf">出票方</label>
                                        <input type="text" class="form-control" id="addcpf" name="cpf">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addgys">供应商</label>
                                        <input type="text" class="form-control" id="addgys" name="gys">

                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addspf">收票方</label>
                                        <input type="text" class="form-control" id="addspf" name="spf">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <div class="form-group">
                                            <label for="addfplx">发票类型</label>
                                            <input type="text" class="form-control" id="addfplx" name="fplx">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addkprq">开票日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addkprq" name="kprq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addfph">发票号</label>
                                        <input type="text" class="form-control" id="addfph" name="fph">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addje">不含税金额</label>
                                        <input type="text" class="form-control" id="addje" name="je">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addsl">税率</label>
                                        <select class="form-control" name="sl">
                                        <option value="3%">3%</option>
                                        <option value="6%">6%</option>
                                        <option value="17%">17%</option>
                                    </select>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addsssj">所属月份</label>
                                        <input type="text" class="form-control form_date" value="" id="addsssj" name="sssj" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addrz">是否认证：</label>
                                        <div>
                                            <label class="checkbox-inline">
                                            <input type="radio" name="rz" id="addyesrz" value="是"/> 是
                                        </label>
                                            <label class="checkbox-inline">
                                            <input type="radio" name="rz" id="addnorz" value="否" checked/> 否
                                        </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addrzsj">认证时间</label>
                                        <input type="text" class="form-control form_date" value="" id="addrzsj" name="rzsj" data-date-format="yyyy-mm-dd" disabled="disabled"
                                            readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存表单</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!--修改面板-->
        <div class="modal fade bs-example-modal-lg" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">修改发票收到登记表</h4>
                    </div>
                    <div class="modal-body">
                        <form id="khzyForm" class="public_form update_form" action="{:U('edit')}" method="post">
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatecpf">出票方</label>
                                        <input type="text" class="form-control" id="updatecpf" name="cpf">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updategys">供应商</label>
                                        <input type="text" class="form-control" id="updategys" name="gys">

                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatespf">收票方</label>
                                        <input type="text" class="form-control" id="updatespf" name="spf">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <div class="form-group">
                                            <label for="updatefplx">发票类型</label>
                                            <input type="text" class="form-control" id="updatefplx" name="fplx">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatekprq">开票日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatekprq" name="kprq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatefph">发票号</label>
                                        <input type="text" class="form-control" id="updatefph" name="fph">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updateje">不含税金额</label>
                                        <input type="text" class="form-control" id="updateje" name="je">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatesl">税率</label>
                                        <select class="form-control" name="sl">
                                        <option value="3%">3%</option>
                                        <option value="6%">6%</option>
                                        <option value="17%">17%</option>
                                    </select>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatesssj">所属月份</label>
                                        <input type="text" class="form-control form_date" value="" id="updatesssj" name="sssj" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">

                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updaterz">是否认证：</label>
                                        <div>
                                            <label class="checkbox-inline">
                                            <input type="radio" name="rz"  class="form-control" id="updateyesrz" value="是"> 是
                                        </label>
                                            <label class="checkbox-inline">
                                            <input type="radio" name="rz"  class="form-control" id="updatenorz" value="否" checked> 否
                                        </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updaterzsj">认证时间</label>
                                        <input type="text" class="form-control form_date" value="" id="updaterzsj" name="rzsj" data-date-format="yyyy-mm-dd" disabled="disabled"
                                            readonly>
                                    </div>
                                </div>
                                <input type="hidden" id="update_id" name="id">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存表单</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <script src="__MYJS__/main.min.js"></script>
        <script src="__MYJS__/main.js"></script>
        <script src="__MYJS__/validator.js"></script>
        <script src="__MYJS__/table.js"></script>
        <script>
            (function () {
                // 修改按钮事件
                $("table").on("click", ".update_btn", function (e) {
                    e.stopPropagation();
                    var id = $(this).attr("data-id");
                    $.ajax({
                        url: "{:U('edit')}",
                        type: 'GET', //GET
                        data: {
                            id: id
                        },
                        success: function (data) {
                            $(".update_form .form-control").each(function (index, val) {
                                var self = this;
                                for (x in data) {
                                    if ($(self).attr("name") == x) {
                                        if (x == "rz" && $(self).attr("name") ==
                                            x) {
                                            $(":radio[name='" + x +
                                                "'][value='" + data[x] +
                                                "']").prop("checked",
                                                "checked");
                                        } else {
                                            $(self).val(data[x]);
                                        }
                                    }
                                }
                            });
                            // 重新更新日期选择器
                            $(".update_form .form_date").each(function (index, val) {
                                if ($(this).val() != "") {
                                    $(this).val(moment($(this).val(),
                                        "YYYYMMDD").format(
                                        "YYYY-MM-DD"))
                                }
                            })
                            $(".update_form .form_date").datetimepicker('update');
                        }
                    })
                    $("#update_id").val(id);
                    $('#updateModal').modal()
                })
                var zdytable = new window.zdytable();
            })()
        </script>
    </body>
</block>

</html>